/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vn.ac.c0910g.assignment.DAO;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import vn.ac.c0910g.assignment.Entity.OrderDetails;
import vn.ac.c0910g.assignment.Entity.OrderDetailsFacade;

/**
 *
 * @author BachLe
 */
public class OrderDetailsDAO {
    OrderDetailsFacade orderDetailsFacade = lookupOrderDetailsFacadeBean();

    public OrderDetailsDAO(){

    }
    private OrderDetailsFacade lookupOrderDetailsFacadeBean() {
        try {
            Context c = new InitialContext();
            return (OrderDetailsFacade) c.lookup("java:global/Alluring_Decors/Alluring_Decors-ejb/OrderDetailsFacade!vn.ac.c0910g.assignment.Entity.OrderDetailsFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    public List<OrderDetails> getAllOrderDetails(){
        return this.orderDetailsFacade.findAll();
    }

    public void addOrderDetails(OrderDetails od){
        orderDetailsFacade.create(od);
    }

    public void updateOrderDetails(OrderDetails od){
        orderDetailsFacade.edit(od);
    }

    public void deleteOrderDetails(OrderDetails od){
        orderDetailsFacade.remove(od);
    }

    public OrderDetails findOrderDetailsById(String Id){
        return orderDetailsFacade.find(Id);
    }
}
